home *** CD-ROM | disk | FTP | other *** search
/ Kids' Bible Fun Pack / Kids' CD-ROM Bible Fun Pack (1997)(Education Publishing Concepts)[Mac-PC].iso / mac / BIBLEC / XTRAS / FileFlex Xtras / -Database Designer / 00003_Script_Drag and Drop Scripts < prev    next >
Text File  |  1995-07-22  |  8KB  |  233 lines

  1. --
  2. -- Panel management handlers
  3. -- 
  4.  
  5. --
  6. -- Create field management handlers
  7. --
  8. on createFieldDown theLine
  9.   global dgDkBlueColor
  10.   put line theLine of field "visTypeList" into theType
  11.   put line theLine of field "visNameList" into field "dragName"
  12.   set the foreColor of member "dragName" to dgDkBlueColor
  13.   set the textSize of member "dragName" to 12
  14.   set the textFont of member "dragName" to "Helvetica"
  15.   set the foreColor of member "dragWidth" to dgDkBlueColor
  16.   set the textSize of member "dragWidth" to 12
  17.   set the textFont of member "dragWidth" to "Helvetica"
  18.   
  19.   if theType = EMPTY then exit
  20.   locShow 46
  21.   case (theType) of
  22.     "character": 
  23.       set panelType to "text panel"
  24.       put line theLine of field "visWidthList" into field "dragWidth"
  25.       locShow 47
  26.     "numeric":   
  27.       set panelType to "numeric panel"
  28.       put line theLine of field "visWidthList" & "," &¼
  29.       line theLine of field "visDecimalsList" into field "dragWidth"
  30.       locShow 47
  31.     "logical":   
  32.       set panelType to "boolean panel"
  33.       locHide 47
  34.     "date":      
  35.       set panelType to "date panel"
  36.       locHide 47
  37.     "memo":      
  38.       set panelType to "memo panel"
  39.       locHide 47
  40.   end case
  41.   set the castNum of sprite 45 to (the number of cast panelType)
  42.   locShow 45
  43.   repeat while the mouseDown is true
  44.     checkFieldPanelDrag theType
  45.     updateStage
  46.   end repeat
  47.   cursor 4
  48.   locHide 45 -- hide the drag bar
  49.   locHide 46
  50.   locHide 47
  51.   updateStage
  52.   case (the frameLabel) of
  53.     "create":
  54.       checkFieldPanelDrop theLine
  55.     "index":
  56.       checkIndexPanelDrop theType, field "dragName", field "dragWidth"
  57.   end case
  58.   cursor -1
  59. end createFieldDown
  60.  
  61. on checkFieldPanelDrag panelType
  62.   put point(the mouseH, the mouseV) into mousePoint
  63.   set the locV of sprite 45 to the mouseV
  64.   set the locH of sprite 45 to the mouseH
  65.   set the locV of sprite 46 to the mouseV - 16
  66.   set the locH of sprite 46 to the mouseH + 25
  67.   if panelType = "character" or panelType = "numeric" then
  68.     set the locV of sprite 47 to the mouseV - 16
  69.     set the locH of sprite 47 to the mouseH + 135
  70.   end if
  71.   case (the frameLabel) of
  72.     "create":
  73.       if inside(mousePoint, the rect of sprite 23) then
  74.         set the castNum of sprite 23 to (the number of cast "trashOpen")
  75.       else
  76.         set the castNum of sprite 23 to (the number of cast "trashClosed")
  77.       end if
  78.     "index":
  79.       if inside(mousePoint, the rect of sprite 13) then
  80.         locShow 14 -- show the hilight bar
  81.       else
  82.         locHide 14
  83.       end if
  84.   end case
  85. end checkFieldPanelDrag
  86.  
  87. on checkFieldPanelDrop theLine
  88.   global topPointsToLine
  89.   put point(the mouseH, the mouseV) into mousePoint
  90.   if inside(mousePoint, the rect of sprite 23) then
  91.     put topPointsToLine + theLine - 1 into delLine
  92.     delete line delLine of field "masterNameList"
  93.     delete line delLine of field "masterTypeList"
  94.     delete line delLine of field "masterWidthList"
  95.     delete line delLine of field "masterDecimalsList"
  96.     put 1 into topPointsToLine
  97.     set the castNum of sprite 23 to (the number of cast "trashClosed")
  98.     doCreateScroll
  99.   end if
  100.   locHide 45
  101.   locHide 46
  102.   locHide 47
  103.   updateStage
  104. end checkFieldPanelDrop
  105.  
  106. on checkIndexPanelDrop theType, theField, theWidth
  107.   global dgYellowColor
  108.   put point(the mouseH, the mouseV) into mousePoint
  109.   if inside(mousePoint, the rect of sprite 13) then
  110.     -- in the drop zone, the index expression area
  111.     locHide 14
  112.     updateStage
  113.     if the number of lines of field "indexExpr" = 5 then
  114.       beep
  115.       exit
  116.     end if
  117.     case (theType) of
  118.       "character":
  119.         put "UPPER(" & theField & ")" into expr
  120.       "numeric":
  121.         put "STR(" & theField & "," & theWidth & ")" into expr
  122.       "logical":
  123.         beep
  124.         exit
  125.       "date":
  126.         put "DTOC(" & theField & ")" into expr
  127.       "memo":
  128.         beep
  129.         exit
  130.     end case
  131.     if field "IndexExpr" = EMPTY then
  132.       put expr into field "IndexExpr"
  133.     else
  134.       put field "IndexExpr" & " +" & RETURN & expr into field "indexExpr"
  135.     end if
  136.   end if
  137.   set the textHeight of member "indexExpr" to 16
  138.   set the textSize of member "indexExpr" to 12
  139.   set the foreColor of member "indexExpr" to dgYellowColor
  140.   
  141. end checkIndexPanelDrop
  142.  
  143.  
  144. --
  145. -- Bin management handlers
  146. -- 
  147. on binDown theSprite, panelType, fieldDefault, widthDefault
  148.   puppetSprite theSprite,TRUE -- turn on the little bar guy
  149.   locHide theSprite
  150.   updateStage
  151.   set the castNum of sprite 45 to (the number of cast panelType)
  152.   locShow 45
  153.   repeat while the mouseDown is true
  154.     checkBinPanelDrag
  155.     updateStage
  156.   end repeat
  157.   checkBinDrop panelType, fieldDefault, widthDefault
  158.   locHide 45 -- hide the drag bar
  159.   locShow theSprite -- show the little mini bar
  160.   updateStage
  161.   puppetSprite theSprite, FALSE
  162. end binDown
  163.  
  164. on checkBinDrop panelType, fieldDefault, widthDefault
  165.   put point(the mouseH, the mouseV) into mousePoint
  166.   if inside(mousePoint, the rect of sprite 3) then
  167.     updateStage
  168.     put word 1 of panelType into theType
  169.     showDefineField theType
  170.     exit
  171.   end if
  172. end checkBinDrop
  173.  
  174. on checkBinPanelDrag
  175.   put point(the mouseH, the mouseV) into mousePoint
  176.   set the locV of sprite 45 to the mouseV
  177.   set the locH of sprite 45 to the mouseH
  178. end checkBinPanelDrag
  179.  
  180.  
  181. on padIt s, theLen, c
  182.   put theLen - (the number of chars of s) into newChars
  183.   put "" into pad
  184.   repeat with i = 1 to newChars
  185.     put c after pad
  186.   end repeat
  187.   put s & pad into theString
  188.   return theString
  189. end padIt
  190.  
  191. on putFieldInfo
  192.   global fieldSpec, topPointsToLine
  193.   put item 1 of fieldSpec into theName
  194.   put item 2 of fieldSpec into theType
  195.   if theType = "C" or theType = "N" then
  196.     put string(item 3 of fieldSpec) into theWidth
  197.   end if
  198.   if theType = "N" then put string(item 4 of fieldSpec) into theDecimals
  199.   
  200.   if field "masterNameList" <> EMPTY then
  201.     put field "masterNameList" & RETURN into field "masterNameList"
  202.     put field "masterTypeList" & RETURN into field "masterTypeList"
  203.     put field "masterWidthList" & RETURN into field "masterWidthList"
  204.     put field "masterDecimalsList" & RETURN into field "masterDecimalsList"
  205.   end if
  206.   case (theType) of
  207.     "C":
  208.       put field "masterNameList" & theName into field "masterNameList"
  209.       put field "masterTypeList" & "character" into field "masterTypeList" 
  210.       put field "masterWidthList" & theWidth into field "masterWidthList"
  211.     "N":
  212.       put field "masterNameList" & theName into field "masterNameList"
  213.       put field "masterTypeList" & "numeric" into field "masterTypeList" 
  214.       put field "masterWidthList" & theWidth into field "masterWidthList"
  215.       put field "masterDecimalsList" & theDecimals into field "masterDecimalsList"
  216.     "D":
  217.       put field "masterNameList" & theName into field "masterNameList"
  218.       put field "masterTypeList" & "date" into field "masterTypeList" 
  219.     "L":
  220.       put field "masterNameList" & theName into field "masterNameList"
  221.       put field "masterTypeList" & "logical" into field "masterTypeList" 
  222.     "M":
  223.       put field "masterNameList" & theName into field "masterNameList"
  224.       put field "masterTypeList" & "memo" into field "masterTypeList" 
  225.   end case
  226.   put the number of lines of field "masterNameList" into theLines
  227.   if theLines > 10 then
  228.     put theLines - 9 into topPointsToLine
  229.   else
  230.     put 1 into topPointsToLine
  231.   end if
  232.   doCreateScroll  
  233. end putFieldInfo